import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    vueDevTools(),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    },
  },
  server:{
    host:'127.0.0.1',
    https: false,
    open: true,
    port: 5177,
    proxy:{
      "/pokemon-battle":{
        target: 'http://111.229.107.38:3000/', // 后台接口前缀
        changeOrigin: true, // 是否允许跨域
        secure: true, // 如果是https接口，需要配置这个参数
        rewrite: (path) => path.replace(/^\/pokemon-battle/, ""),
      }
    }
  }
})
